import { PaginationParamsType, ParamsObjType as _ParamsObjType } from "@/library/common/types"

type _UseAllType = {
    Id: number
    ShopCode: string
    Role: string
    Username: string
    Enable: boolean
    Nickname: string
    RealName: string
    PasswordSalt: string
    Password: string
    UpdatedAt: string
    CreatedAt: string
    Range: string
}

/**
 * 查询参数
 */
export type SelectParamsType = Partial<Pick<_UseAllType, "Id" | "ShopCode" | "Role" | "Username" | "Nickname" | "RealName" | "Range">> & PaginationParamsType & {
    Enable?: number
}

/**
 * 查询响应 Data
 */
export type DataType = Omit<_UseAllType, 'Range'>

/**
 * 查询参数
 */
export type ParamsType = {
    Role: _ParamsObjType[]
}
export type ParamsObjType = Partial<Record<keyof ParamsType, Record<string, string>>>

/**
 * 新增
 */
export type InsertType = Pick<_UseAllType, "ShopCode" | "Role" | "Username" | "Nickname" | "RealName" | "PasswordSalt" | "Password">

/**
 * 更新
 */
export type UpdateType = Pick<_UseAllType, "Id" | "Role" | "Username" | "Nickname" | "RealName">

export type EditDialogType = {
    visible: boolean
    editForm: FindInterType<InsertType, UpdateType>
}

/**
 * 将 T1、T2 中的交叉类型设为必选, 其余为可选
 */
type FindInterType<T1, T2> = Partial<(T1 & T2)> & Required<(T1 | T2)>

/**
 * 设置是否启用
 */
export type SetEnableType = Pick<_UseAllType, "Id" | "Enable">